On a packet-switched network such as the Internet, traffic between a source and a destination is in the form of one or more discrete units, or datagrams. The creation of datagrams is typically performed by a number of software protocols working in coordination. These protocols are typically visualized as a vertical stack of layers. Each layer/protocol accepts a datagram from an adjacent layer/protocol, performs a specific set of one or more tasks on that datagram, and then delivers the resulting datagram to the next layer/protocol in the stack.
NAT (Network Address Translation) is a functionality of a router that allows binding of private IP addresses to public IP address. Another advantage of NAT is that it allows minimizing IPv4 address space required in a network by segmenting network into independent Network segments. NAT functionality requires parsing IPv4 packet to layer 4 fields. These layer 4 fields along with IPv4 address creates unique address which can be assigned to a host or to a network. For example:    Private IP Address 192.168.1.100 maps to public IP address 138.120.1.100 port 2000    Private IP Address 192.168.1.101 maps to public IP Address 138.120.1.100 port 2001    Private IP Address 192.168.1.102 maps to public IP Address 138.120.1.100 port 2002
During the course of routing IP datagrams, it is occasionally necessary to break such datagrams into a sequence of smaller IP datagrams, for example, to meet the constraints of an intermediate network or router in the transmission path. This operation is called IP packet fragmentation. Such a constraint can be defined by a Maximum Transmission Unit (MTU) parameter configured on a router. An unfragmented IP datagram is called a packet, and each smaller IP datagram that results from breaking up a packet is called a packet fragment (or fragment).
IPv4 fragmentation (described in IETF publication RFC 791) is a process by which a single IPv4 packet can be segmented into multiple IPv4 packet fragments. Since the IPv4 fragmentation process only duplicates the IPv4 header, without layer 4 header (i.e.: transport layer, e.g.: Terminal Control Protocol (TCP) header or User Datagram Protocol (UDP) header), only the first fragment of the original packet contains layer 4 header. Subsequent fragments do not contain layer 4 header. A first fragment is defined as having “More Fragments” (“MF”) equal to 1 and Fragment Offset (“offset”) equal 0 in the IPv4 header. Subsequent fragments of the packet are defined as having “offset” equal non-zero value in the IPv4 header. The last fragment of a packet is defined as having “MF” equal to zero in the IPv4 header and “offset” equal to a non-zero value.
FIG. 1 illustrates a fragmented IPv4 packet 100. Packet 100 is fragmented into packet fragments 102, 104, 106. First packet fragment 102 contains IPv4 Header 108, layer 4 header 110 and data 112. Middle packet fragments 104 and the last packet fragment 106 do not contain a layer 4 header.
Since it is possible to have packet fragments in a NAT router, fragments of a packet must typically be reassembled into a complete packet prior to performing a NAT operation, in order to associate the layer 4 header information with each of the packet fragments. Generally it is very demanding on resources to reassemble the packet and then perform a NAT operation on the packet. Therefore, improvements to NAT routers to improve the efficiency of a NAT operation on packet fragments is highly desirable.